package Work01;

import java.util.Random;

//定义卖票线程类(任务类)
public class TicketThread implements Runnable{
    private Tickets ti;

    public TicketThread() {

    }

    public TicketThread(Tickets ti) {
        this.ti = ti;
    }

    //重写run方法
    @Override
    public void run() {
        //定义售出票数
        for (int i = 0; i <100 ; i++) {
            Random r = new Random();
            //定义一次售票最多不超过两张
            int a = r.nextInt(2) + 1;
            try {
                ti.ticket(a);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
